package com.lemontree.web.serviceImpl;

import com.lemontree.web.dao.EmailConfigMapper;
import com.lemontree.web.entity.EmailConfig;
import com.lemontree.web.entity.EmailConfigExample;
import com.lemontree.web.service.EmailConfigService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: YLBG-YCY-1325
 * @Description: 邮箱配置
 * @Date: 2017/3/28
 */
public class EmailConfigServiceImpl implements EmailConfigService {
    @Autowired
    private EmailConfigMapper configMapper;

    public EmailConfig getEmailConfigs() {
        List<EmailConfig> emailConfigs = new ArrayList<EmailConfig>();
        EmailConfigExample emailConfigExample = new EmailConfigExample();
        EmailConfigExample.Criteria  criteria =  emailConfigExample.createCriteria();
        criteria.andDeleteTimeIsNull();
        emailConfigExample.setOrderByClause("id");
        emailConfigs = configMapper.selectByExample(emailConfigExample);
        if (CollectionUtils.isNotEmpty(emailConfigs)){
            return emailConfigs.get(0);
        }
        return null;
    }
}
